﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OnlineShop.Models;
using OnlineShop.Common;
using OnlineShop.Models.ViewModels;

namespace OnlineShop.Controllers
{
    public class SearchController : BaseController
    {
        #region Repository
        private IOnlineShopRepository repository;

        public SearchController():this(new EFOnlineShopRepository())
        {
        }

        public SearchController(EFOnlineShopRepository eFOnlineShopRepository)
        {
            this.repository = eFOnlineShopRepository;
        }

        #endregion

        //
        // GET: /Search/

        [ChildActionOnly]
        public ActionResult ShowSearchBox()
        {
            var listCategory = new List<CategoryModel>();
            foreach (var item in repository.GetListCategory())
            {
                listCategory.Add(item.ToModel());
            }

            var searchModel = new SearchAdvModel()
            {
                Category = listCategory,
                KeyWord = "",
                MinPrice = new List<SearchAdvModel.PriceModel>() 
                {   
                    new SearchAdvModel.PriceModel(1000000),
                    new SearchAdvModel.PriceModel(2000000),
                    new SearchAdvModel.PriceModel(3000000),
                    new SearchAdvModel.PriceModel(4000000),
                    new SearchAdvModel.PriceModel(5000000),
                    new SearchAdvModel.PriceModel(6000000),
                    new SearchAdvModel.PriceModel(8000000),
                    new SearchAdvModel.PriceModel(10000000),
                },
                MaxPrice = new List<SearchAdvModel.PriceModel>() 
                {   
                    new SearchAdvModel.PriceModel(5000000),
                    new SearchAdvModel.PriceModel(10000000),
                    new SearchAdvModel.PriceModel(15000000),
                    new SearchAdvModel.PriceModel(20000000),
                    new SearchAdvModel.PriceModel(25000000),
                    new SearchAdvModel.PriceModel(30000000),
                    new SearchAdvModel.PriceModel(50000000),
                    new SearchAdvModel.PriceModel(10000000),
                },
            };

            return PartialView("SearchBox",searchModel);
        }

    }
}
